use std::fmt;

#[derive(Debug)]
pub enum PlayerError {
    FFmpegError(ffmpeg_next::Error),
    IoError(std::io::Error),
    Other(String),
}

impl fmt::Display for PlayerError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self {
            PlayerError::FFmpegError(e) => write!(f, "FFmpeg error: {}", e),
            PlayerError::IoError(e) => write!(f, "IO error: {}", e),
            PlayerError::Other(s) => write!(f, "Error: {}", s),
        }
    }
}

impl std::error::Error for PlayerError {}

impl From<ffmpeg_next::Error> for PlayerError {
    fn from(error: ffmpeg_next::Error) -> Self {
        PlayerError::FFmpegError(error)
    }
}

impl From<std::io::Error> for PlayerError {
    fn from(error: std::io::Error) -> Self {
        PlayerError::IoError(error)
    }
}

impl From<String> for PlayerError {
    fn from(error: String) -> Self {
        PlayerError::Other(error)
    }
}
